﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Web;

namespace RhotCMS.Hubs
{
    public class HubUserManager
    {
        private static volatile HubUserList _hubUserList;

        public HubUserManager()
        {
            if(_hubUserList==null)
                _hubUserList = new HubUserList();
        }

        public void Add(string connectionId, IIdentity identity)
        {
            _hubUserList[connectionId] = identity;
        }

        public void Remove(string connectionId)
        {
            _hubUserList[connectionId] = null;
        }

        public IIdentity Get(string connectionId)
        {
            return _hubUserList[connectionId];
        }

        public IEnumerable<IIdentity> GetAll()
        {
            return _hubUserList.All;
        }

        public int GetUserCountByName(string name)
        {
            return _hubUserList.GetUserCountByName(name);          
        }
    }
}